Conversation
- Introduced a new workflow `outputGuardrails` in `output-guardrails.ts` to enhance output processing. - Implemented a sequential processing flow: - Added a `TokenLimiterProcessor` to limit tokens to a maximum of 256,000. - Included a `BatchPartsProcessor` to batch stream chunks with a size of 10, emitting on non-text. - Added parallel processing for independent checks: - Integrated a `PIIDetector` with a redaction strategy using the model `openrouter/google/gemma-4-31b-it:free`. - Integrated a `ModerationProcessor` with a blocking strategy using the same model. - Mapped the output to retain transformed messages from the `PIIDetector`. - Added a sequential step for `SystemPromptScrubber` to scrub the output based on the previous redaction, using a placeholder text of `[REDACTED]`.
There was a problem hiding this comment.
Sorry @ssdeanx, your pull request is larger than the review limit of 150000 diff characters
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details. |
|
Caution Review failedPull request was closed or merged during review Summary by CodeRabbit
WalkthroughLarge-scale refactor introducing modular chat settings routes, UI improvements (resizable sidebars, tooltips), scorer framework migration, browser runtime configuration hardening, and authentication standardization across agents, networks, hooks, and components. Multiple pages wrap into shared Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChatPageShell
participant ChatProvider
participant MainSidebar
participant ChatMessages
participant Transport
User->>ChatPageShell: Navigate to dashboard/settings page
ChatPageShell->>ChatProvider: Initialize context
ChatProvider->>Transport: Create DefaultChatTransport with credentials:'include'
ChatPageShell->>MainSidebar: Render sidebar with tooltips
MainSidebar->>MainSidebar: Load workspaces, threads, vectors
User->>ChatMessages: Load or send message
ChatMessages->>ChatProvider: Extract thought summary from metadata
ChatProvider->>Transport: Send request with SSE credentials
Transport-->>ChatMessages: Stream response chunks
ChatMessages->>ChatMessages: Validate complete messages, skip incomplete
ChatMessages-->>User: Render thought summary & message content
sequenceDiagram
participant User
participant UserPage (Overview)
participant UserSettingsLayout
participant ChatSettingsShell
participant UserSettingsPanel
participant BetterAuth
User->>UserPage: Navigate to /chat/user
UserPage->>UserPage: Render section cards (Profile, Security, Sessions, etc.)
User->>UserPage: Click "Profile" card
UserPage-->>User: Navigate to /chat/user/profile
UserSettingsLayout->>ChatSettingsShell: Initialize with sections nav
ChatSettingsShell->>ChatSettingsShell: Highlight active section path
ChatSettingsShell->>UserSettingsPanel: Render with section="profile"
UserSettingsPanel->>BetterAuth: Load profile data
BetterAuth-->>UserSettingsPanel: Return user profile
UserSettingsPanel-->>User: Render profile-only form
User->>UserSettingsPanel: Submit profile changes
UserSettingsPanel->>BetterAuth: Update via Better Auth mutation
BetterAuth-->>UserSettingsPanel: Confirm update
UserSettingsPanel-->>User: Show success message
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Mastra processor workflow (outputGuardrails) intended to enforce output guardrails (token limiting, batching, PII redaction, moderation, and prompt scrubbing), and also includes broad refactors across Mastra networks/agents plus multiple chat/auth UI hardening updates.
Changes:
- Added a new
outputGuardrailsprocessor workflow that chains token limiting + batching, runs PII/moderation checks in parallel, and then scrubs system prompts. - Standardized many coordinator networks (and some agents) to use the shared
createSupervisorPatternScorer(...)/createSupervisorAgentPatternScorer(...)primitives instead of duplicating scorer plumbing. - Updated auth + chat UI surfaces (Better Auth redirect normalization, modular settings routes/shell, chat transport credentials, sidebar/workspace normalization), plus added
zlib-syncdependency and updated ignore/docs artifacts.
Reviewed changes
Copilot reviewed 97 out of 100 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mastra/processors/output-guardrails.ts | Adds new output guardrails workflow (token limit, batching, PII/moderation, scrubbing). |
| src/mastra/networks/securityNetwork.ts | Migrates local completion scorers to createSupervisorPatternScorer. |
| src/mastra/networks/marketingAutomationNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/learningNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/index.ts | Migrates primary network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/financialIntelligenceNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/devopsNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/dataPipelineNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/contentCreationNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/codingTeamNetwork.ts | Migrates network scorers to shared supervisor scorer primitive. |
| src/mastra/networks/AGENTS.md | Updates network guidance to prefer shared scorer primitives while keeping local signals. |
| src/mastra/index.ts | Registers browserAgent in Mastra agent registry. |
| src/mastra/config/libsql.ts | Adjusts memory/embedder options and logging for LibSQL-backed memory/vector. |
| src/mastra/auth.ts | Normalizes Google redirect URI + trusted origins; refactors provider env handling. |
| src/mastra/agents/webResearchAgent.ts | Removes unused processor import(s). |
| src/mastra/agents/weather-agent.ts | Removes unused imports / token limiter wiring. |
| src/mastra/agents/translationAgent.ts | Migrates scorers to createSupervisorAgentPatternScorer. |
| src/mastra/agents/stockAnalysisAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/scriptWriterAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/researchPaperAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/researchAgent.ts | Adds env-gated GitHub channel adapter, handler refactor, model selection changes, tool search processor. |
| src/mastra/agents/reportAgent.ts | Changes model selection; removes output token limiter. |
| src/mastra/agents/recharts.ts | Adjusts models; removes/disabled token limiter usage. |
| src/mastra/agents/package-publisher.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/noteTakerAgent.ts | Updates model selection. |
| src/mastra/agents/learningExtractionAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/index.ts | Exports browserAgent. |
| src/mastra/agents/image_to_csv.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/image.ts | Updates model selection. |
| src/mastra/agents/graphingAgents.ts | Adjusts Unicode normalizer settings and removes/disabled token limiter usage. |
| src/mastra/agents/excalidraw_validator.ts | Updates model + modalities; removes/disabled output token limiter usage. |
| src/mastra/agents/editorAgent.ts | Updates model + modalities. |
| src/mastra/agents/documentProcessingAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/dataExportAgent.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/dane.ts | Updates models + modalities. |
| src/mastra/agents/contentStrategistAgent.ts | Updates model + modalities. |
| src/mastra/agents/calendarAgent.ts | Updates model selection. |
| src/mastra/agents/businessLegalAgents.ts | Removes/disabled output token limiter usage. |
| src/mastra/agents/browserAgent.ts | Adds stronger deterministic browser-verification contract + default options. |
| src/mastra/agents/AGENTS.md | Updates agent conventions (shared scorer primitives, browser/channel guidance). |
| package.json | Adds zlib-sync dependency. |
| package-lock.json | Locks zlib-sync and updates lockfile contents. |
| memory-bank/progress.md | Adds progress updates documenting various changes. |
| memory-bank/activeContext.md | Adds active context updates documenting various changes. |
| lib/hooks/use-persistent-store.ts | Adjusts store setState calls to satisfy overloads (functional updater). |
| lib/hooks/use-mastra-query.ts | Normalizes workspace response shape; introduces DEFAULT_VECTOR_STORE_NAME. |
| lib/auth-client.ts | Uses public env vars for One Tap; adds helper wrappers; keeps credentials: 'include'. |
| app/workflows/providers/workflow-context.tsx | Adds credentials: 'include' to workflow chat transport. |
| app/networks/providers/network-context.tsx | Adds credentials: 'include' to network chat transport. |
| app/login/signup/page.tsx | Wraps searchParams usage in Suspense and refactors auth client calls. |
| app/login/page.tsx | Wraps searchParams usage in Suspense and refactors auth client calls. |
| app/chat/workspaces/page.tsx | Wraps page in shared chat shell and fixes workspace list consumption. |
| app/chat/workflows/page.tsx | Wraps page in shared chat shell. |
| app/chat/workflows/[workflowId]/page.tsx | Wraps detail page in shared chat shell. |
| app/chat/user/sessions/page.tsx | Adds modular user settings route (sessions). |
| app/chat/user/security/page.tsx | Adds modular user settings route (security). |
| app/chat/user/profile/page.tsx | Adds modular user settings route (profile). |
| app/chat/user/page.tsx | Converts user settings into an overview landing page. |
| app/chat/user/layout.tsx | Adds shared settings layout using ChatSettingsShell. |
| app/chat/user/danger-zone/page.tsx | Adds modular user settings route (danger-zone). |
| app/chat/user/api-keys/page.tsx | Adds modular user settings route (api-keys). |
| app/chat/user/_components/user-settings-panel.tsx | Adds section-based rendering for modular settings routes. |
| app/chat/tools/page.tsx | Wraps page in shared chat shell. |
| app/chat/providers/chat-context.tsx | Provider-metadata parsing hardening + credentials + message validation gating. |
| app/chat/observability/page.tsx | Wraps page in shared chat shell. |
| app/chat/mcp-a2a/page.tsx | Wraps page in shared chat shell. |
| app/chat/logs/page.tsx | Wraps page in shared chat shell. |
| app/chat/layout.tsx | Adds Suspense wrapper around server auth gate. |
| app/chat/harness/page.tsx | Wraps page in shared chat shell. |
| app/chat/evaluation/page.tsx | Wraps page in shared chat shell. |
| app/chat/dataset/page.tsx | Wraps page in shared chat shell. |
| app/chat/config/agents.ts | Updates vector-store wording (no longer PgVector-specific). |
| app/chat/components/nested-agent-chat.tsx | Adds credentials: 'include' to nested-agent transport. |
| app/chat/components/chat.utils.ts | Adds provider-agnostic thought summary extraction. |
| app/chat/components/chat-sidebar.tsx | Adapts to normalized workspaces + vector-store selection; layout tweaks. |
| app/chat/components/chat-settings-shell.tsx | Adds reusable settings shell wrapper for modular settings routes. |
| app/chat/components/chat-page-shell.tsx | Adds hideHeader option and spacing tweaks. |
| app/chat/components/chat-messages.tsx | Provider-metadata parsing hardening + message validation gating. |
| app/chat/components/chat-layout.tsx | Makes chat sidebar resizable and improves layout constraints. |
| app/chat/admin/users/page.tsx | Adds modular admin settings route (users). |
| app/chat/admin/runtime/page.tsx | Adds modular admin settings route (runtime). |
| app/chat/admin/page.tsx | Converts admin settings into an overview landing page. |
| app/chat/admin/layout.tsx | Adds shared settings layout using ChatSettingsShell. |
| app/chat/admin/_components/admin-management-panel.tsx | Adds section-based rendering for modular admin settings routes. |
| app/chat/AGENTS.md | Documents new modular settings shell + workspace hook normalization. |
| README.md | Adds new screenshot to development section. |
| .gitignore | Updates ignore patterns for various local artifacts. |
| .env.example | Updates Better Auth + Google callback/public env examples. |
Comments suppressed due to low confidence (1)
app/login/page.tsx:61
- The login page still writes
REMEMBERED_IDENTIFIER_KEY, but the effect that restores the saved identifier fromlocalStoragewas removed. This breaks the "remember identifier" UX (users won't see their saved identifier prefilled). Re-add auseEffectthat readswindow.localStorage.getItem(REMEMBERED_IDENTIFIER_KEY)on mount and updatesidentifier/rememberIdentifieraccordingly.
| .then(createStep(new BatchPartsProcessor( | ||
| { batchSize: 10, emitOnNonText: false }, | ||
|
|
||
| ))) |
| socialProviders, | ||
| baseURL: process.env.BETTER_AUTH_URL ?? 'http://localhost:3000', | ||
| secret: process.env.BETTER_AUTH_SECRET ?? 'supersecret', |
| }, | ||
| maxParallelCalls: 5, // Limit parallel embedding calls to avoid rate limits | ||
| //maxParallelCalls: 10, // Limit parallel embedding calls to avoid rate limits | ||
| providerOptions: { |
| "v0-sdk": "^0.16.4", | ||
| "zlib-sync": "^0.1.10", | ||
| "zod": "^4.3.6" |
There was a problem hiding this comment.
Code Review
This pull request introduces modular route groups for user and admin settings, normalizes workspace data handling, and adds a shared shell for chat-related surfaces. It also hardens chat-provider metadata extraction, fixes hydration mismatches in authentication routes, and introduces a supervisor-pattern scorer for agent evaluation. I have identified a critical issue where the .gitignore file ignores itself, a high-severity issue regarding the incorrect usage of the Pages Router singleton in an App Router project, and a discrepancy between the intended behavior and implementation of the BatchPartsProcessor.
| .playwright-mcp/page-2026-04-15T08-44-34-033Z.yml | ||
| .playwright-mcp/page-2026-04-15T07-36-00-846Z.yml | ||
| .playwright-mcp/page-2026-04-15T07-34-28-100Z.yml | ||
| .gitignore |
There was a problem hiding this comment.
| WrenchIcon, | ||
| } from 'lucide-react' | ||
| import { cn } from '@/lib/utils' | ||
| import router from 'next/router' |
There was a problem hiding this comment.
You've imported router from next/router, which is intended for the Pages Router. Since this project uses the App Router, you should use the useRouter hook from next/navigation instead. Using the singleton from next/router is deprecated in the App Router and can lead to unexpected behavior and bugs.
Please remove this import and use useRouter from next/navigation inside the MainSidebar component, as it was before this change.
| // Sequential: limit tokens first, then batch stream chunks | ||
| .then(createStep(new TokenLimiterProcessor({ limit: 256000 }))) | ||
| .then(createStep(new BatchPartsProcessor( | ||
| { batchSize: 10, emitOnNonText: false }, |
There was a problem hiding this comment.
There is a discrepancy between the PR description, which states that the BatchPartsProcessor is 'emitting on non-text', and the code where emitOnNonText is set to false. If the intention is to process non-text parts immediately without batching, this value should be true.
| { batchSize: 10, emitOnNonText: false }, | |
| { batchSize: 10, emitOnNonText: true }, |
outputGuardrailsinoutput-guardrails.tsto enhance output processing.TokenLimiterProcessorto limit tokens to a maximum of 256,000.BatchPartsProcessorto batch stream chunks with a size of 10, emitting on non-text.PIIDetectorwith a redaction strategy using the modelopenrouter/google/gemma-4-31b-it:free.ModerationProcessorwith a blocking strategy using the same model.PIIDetector.SystemPromptScrubberto scrub the output based on the previous redaction, using a placeholder text of[REDACTED].